package com.bluegalaxy.nhb.snapi.controller.api.ck;

import com.alibaba.fastjson.JSONObject;
import com.bluegalaxy.nhb.snservice.domain.constant.AppConstant;
import com.bluegalaxy.nhb.snservice.domain.vo.api.R;
import com.bluegalaxy.nhb.snservice.service.execute.AddColumnService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;

/**
 * 基础指标监控
 */
@RestController
@RequestMapping(AppConstant.APPLICATION_NAME+"/addcolumn")
@Api(value = "增加CK字段", tags = "增加CK字段API")
public class AddColumnController {
    private static Log log = LogFactory.getLog(AddColumnController.class);

    @Autowired
    private AddColumnService addColumnService;

    @ResponseBody
    @PostMapping("/column")
    @ApiOperation(value = "增加事件属性字段", notes = "增加事件属性字段")
    public R addColumn(@RequestBody String  jsonString) {
        //String转json
        JSONObject obj = JSONObject.parseObject(jsonString);
        String columnName= obj.getString("columnName");
        String columnComment= obj.getString("columnComment");
        Boolean flag=addColumnService.addColumn(columnName,columnComment);
        Map<String, Object> paramMap =new HashMap<>();
        paramMap.put("flag",flag);
        return R.data(paramMap);
    }
}
